package com.foreknow.demo4;

import java.util.Scanner;

/**
 * 通过while循环查询商品的价格
 */
public class Loopdemo2 {
    public static void main(String[] args) {
//        int x=1;
//        while(x<3){
//            System.out.println("x="+x);
//            x++;
//        }
//        System.out.println("over........");
        String name = "";//商品的名称
        double price = 0.0;//商品的价格
        System.out.println("商品管理系统");
        System.out.println("*****************************");
        System.out.println("请选择购买商品的编号：");
        System.out.println("1.足球    2.篮球    3.吉他    ");
        System.out.println("*****************************");
        Scanner input = new Scanner(System.in);

        String answer = "y";
        while(answer.equals("y")) {
            System.out.println("请输入商品的编号：");
            int goodsNO = input.nextInt();
            switch (goodsNO) {
                case 1:
                    name = "足球";
                    price = 245.5;
                    break;
                case 2:
                    name = "蓝球";
                    price = 345.5;
                    break;
                case 3:
                    name = "吉他";
                    price = 5345.5;
                    break;
            }
            System.out.println(name + "---------" + price);
            System.out.println("是否继续(y/n)");
            answer = input.next();
        }
        System.out.println("退出程序！！！！！！！");
    }
}
